package TCPThread.file;

import com.sun.source.tree.NewArrayTree;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.UUID;
import java.util.concurrent.*;

public class Recvice {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(10086);

        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                3,//核心线程数量
                16,//线程总大小
                60,//等待时间
                TimeUnit.SECONDS,//时间单位
                new ArrayBlockingQueue<>(2),//队列
                Executors.defaultThreadFactory(),//线程工厂，
                new ThreadPoolExecutor.AbortPolicy()//阻塞队列
        );
        while (true) {
            Socket socket  = serverSocket.accept();
            //new Thread(new MyRunable(socket)).start();
            threadPoolExecutor.submit(new  MyRunable(socket));
        }
    }
}
